﻿<%@ Page Language="C#" Title ="更改分组" AutoEventWireup="true" CodeBehind="ChangeUserGroup.aspx.cs" Inherits="chatblog.usercate.dialog.ChangeUserGroup" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title></title>
    <style   type ="text/css" >
        .inputText
        {
            width :180px;
        }       
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div style =" width :400px; height:300px;">
        <table>
            <tr>
                <td style=" text-align :right; width :150px ">
                    您的好友：
                </td>
                <td>
                    <span id="FriendIdSpan"></span>
                </td>
            </tr>
            <tr>
                <td style=" text-align :right; width :150px ">
                    原来的好友组：
                </td>
                <td id="OriginGroupListTd">
                    <select id="OriginGroupListSelect" disabled ="true">
                          
                    </select>
                </td>
            </tr>
            <tr>
                <td style=" text-align :right ">
                    修改后的好友组：
                </td>
                <td id="NewGroupListTd">
                    <select id="NewGroupListSelect"></select>
                </td>
            </tr>
            <tr>
                <td style =" text-align:right ">
                    <input  type ="button"  value="保存"  onclick ="changeGroupId();"/>
                </td>
                <td style =" text-align:left "> 
                    <input  type ="button"  value="取消"  onclick="window.close();"/>
                </td>
            </tr>
        </table>
        <input  type ="hidden" id="GroupIdhidden"/>
    </div>
     <script src="common.js" type="text/javascript"></script>
    <script type ="text/javascript" >
        var oldIndex = -1;
        //修改好友分组
        function changeGroupId(userid, oldGroupid, newGroupid) {
            var result = chatblog.usercate.chRoom.UpdateUserGroup(userid, oldGroupid, newGroupid);
            var doorPDiv = document.getElementById(doorPId);
            doorPDiv.innerHTML = chatblog.usercate.chRoom.GetDoorPInnerHtml().value;
            InitAgain();
        }
               
        
        function windowonload() {
            if (window.location.search == "") {
                alert("对不起，没有相应的参数！");
                closeWithNoTip();
            }
            else {
                var userid = getQueryString("userid");
                var groupid = getQueryString("groupid");
                if (userid == null || userid == "" || groupid == "" || groupid == null) {
                    alert("对不起，您传递的参数不正确！");
                    closeWithNoTip();
                }
                paramsAllready = true;
                document.getElementById("FriendIdSpan").innerHTML = userid;
                document.getElementById("GroupIdhidden").value = groupid;
                var result = chatblog.usercate.chRoom.GetGroupListHtml(groupid);
                if (result.value != null) {
                    var groupList = eval("("+result.value+")").groupList;
                    var originSelect = document.getElementById("OriginGroupListSelect");
                    var newSelect = document.getElementById("NewGroupListSelect");
                    for (var i = 0; i < groupList.length; i++) {
                        var newOptionEle = document.createElement("option");
                        newOptionEle.id = groupList[i].id;
                        newOptionEle.value = groupList[i].name;
                        newOptionEle.selected = groupList[i].selected;
                        newOptionEle.innerHTML = groupList[i].name;
                        originSelect.appendChild(newOptionEle);
                        newSelect.appendChild(newOptionEle.cloneNode(true));
                        if (groupList[i].selected == true)
                            oldIndex = i;
                    }
                }   
            }
        }
        window.onload = windowonload;
        //修改好友昵称
        function changeGroupId() {
            if (paramsAllready == true && window.opener !=null) {
                var userid = getQueryString("userid");
                var groupid = getQueryString("groupid");
                var newSelect = document.getElementById("NewGroupListSelect");
                if (newSelect.selectedIndex  >=0  ) {
                    var result = chatblog.usercate.chRoom.UpdateUserGroup(userid, groupid, newSelect[newSelect.selectedIndex].id);
                    window.opener.RefreshGroupDiv();
                    window.close(); 
                }
            }
        }
    </script>  
    </form>
</body>
</html>
